var SERVER_URL = 'ws://localhost:1337/game';
var server;
var GameID; // game id to join, for testing

var log = function(str) {
  var msg = document.createElement('div');
  msg.innerHTML = str
  document.getElementById('debug').appendChild(msg);
};

var Renderer = Display;

var webui   = new Renderer('webui  ', 'game');
var cmdline = new Renderer('cmdline');

var webui_client   = new CatanClientHost();
var cmdline_client = new CatanClientPlayer();
webui_client.name       = 'webui  ';
webui_client.display    = webui;
webui_client.game       = TestGame;
cmdline_client.name     = 'cmdline';
cmdline_client.display  = cmdline;
cmdline_client.game     = TestGame;

var webui_server;
var cmdline_server;

(function main() {
  if ("WebSocket" in window) {
    log("Yay! WebSockets are available. Connecting...");
    webui_server   = new CatanServer('webui  ', webui_client,   SERVER_URL);
    cmdline_server = new CatanServer('cmdline', cmdline_client, SERVER_URL);
    webui.server    = webui_server;
    cmdline.server  = cmdline_server;
  }
  else {
    log('Oh noes! WebSockets isn\'t available =(');
  };
})();
